import Vue from 'vue'

// 默认用户信息
const userInfo = {}

export default {
	namespaced: true,
	state: {
		token: '',
		userInfo,
	},
	mutations: {
		setToken(state, token) {
			state.token = token
		},
		setUserInfo(state, userInfo) {
			state.userInfo = userInfo
		},
		// 清除所有状态
		clearAll(state) {
			state.token = ''
			state.userInfo = {
				...userInfo
			}
		},
	},
	actions: {
		// 退出
		logout({
			commit,
			state
		}) {
			commit('clearAll')
		}
	},
	getters: {},
}